<template>
	<view class="pages">
		<view class="textareaBox">
			<textarea v-model="comment" placeholder="请输入评价内容" />
		</view>
		<view class="zan">
			<!-- <view>赞<image @click="zan" :src="good==0?'../../static/cut/zan.png':'../../static/cut/ONzan.png'" mode=""></image></view> -->
			<!-- <view>很差<image @click="cha" :src="bad==0?'../../static/cut/cai.png':'../../static/cut/ONcai.png'" mode=""></image></view> -->
			<view>赞<image @click="zan" :src="'../../static/cut/zan.gif'" mode=""></image></view>
			<view>很差<image @click="cha" :src="'../../static/cut/cai.png'" mode=""></image></view>
		</view>
		<view class="row">
			<input type="text" v-model="name" placeholder="请留下您的姓名/昵称"/>
		</view>
		<view class="row">
			<input type="phone" v-model="tel" placeholder="请留下您的电话"/>
		</view>
		<button class="commentSubmit" type="primary" @click="submitComment()">提交评价</button>
	</view>
</template>

<script>
	import API from '../../common/api.js';
	
	export default {
		data(){
			return{
				name: "",
				tel:"",
				comment:"",
				good: 0,
				bad: 0
			}
		},
		methods:{
			cha(){
				this.comment = "您企业或者安全责任人对该风险点的安全风险管控双重预防的巡检、隐患自查、自报，整改闭环既定工作，不到位，请重视！安全生产，警钟长鸣！";
				this.good = 0;
				this.bad = 1;
			},
			zan(){
				this.comment = "您企业或者责任人对该风险点管控，做得很好，请继续保持！";
				this.good = 1;
				this.bad = 0;
			},
			submitComment(){
				if(!this.name&&!this.tel){
					uni.showToast({
						title:"请输入您的名字和电话",
						icon:'none'
					})
					return false;
				}
				var that = this;
				uni.request({
					url:API.saveFxComment,
					data:{
						'fx_comment.name': that.name,
						'fx_comment.tel': that.tel,
						'fx_comment.comment': that.comment,
						'fx_comment.good': that.good,
						'fx_comment.bad': that.bad
					},
					method:"POST",
					header:API.get_head(),
					success: (res) => {
						console.log("getMoreSubUser==>", res);
						if(res.data.message != "success"){
							uni.showToast({
								title:res.data.message,
								icon:"none"
							});
						}
					},
					fail: () => {
						uni.showToast({
							title:"加载失败",
							icon:'none'
						})
					}
				});
			}
		}
	}
</script>

<style>
	page{background:#FFFFFF;}
	.pages{padding:20upx;}
	.textareaBox{border:1px solid #F2F2F2;padding:10upx;border-radius:10upx;}
	textarea{width:100%;}
	.zan{display:flex;justify-content: flex-end;margin:20upx 0;align-items: center;}
	.zan view{margin-left:20upx;}
	.zan image{width:50upx;height:50upx;vertical-align:middle;margin-left:20upx;}
	.row {margin-bottom:20upx;}
	.row input{height:30upx;border:1px solid #F2F2F2;border-radius:5upx;padding:10upx;}
</style>
